home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1984 June
/
1984-06.d64
/
random numbers
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
2KB
|
107 lines
1 print"[147] press r[146] to randomize."
2 geta$:ifa$=""then2
3 ifa$="r"thenx=rnd(-ti)
5 poke56,27:clr:print"[147] please wait..."
7 b=7168:c=7679:fora=btoc:pokea,0:next
10 b=885:c=947:fora=btoc:readd:pokea,d:next
20 print"[147] v[146]ic or 64?"
25 print" press v[146] for vic"
26 print" return[146] for 64."
30 geta$:ifa$=""then30
35 ifa$<>"v"then50
40 poke888,39:poke892,148
50 print"[147] press f1[146] to test"
51 print" random seeds."
60 print" press f3[146] to test"
61 print" basic rnd[146] command."
70 geta$:ifa$=""then70
80 ifa$="[133]"thengoto1000
90 ifa$="[134]"thengoto2000
100 goto50
885 data165,197,201,4,240,55,32,151
893 data224,165,143,133,251,169,254,133
901 data253,169,27,133,254,160,255,24
909 data165,253,105,2,133,253,165,254
917 data105,0,133,254,200,196,251,208
925 data238,160,0,24,177,253,105,1
933 data145,253,200,177,253,105,0,145
941 data253,201,255,208,195,96,0,0
1000 print"[147] press 1-5 to test"
1010 print" random seeds."
1020 print" press test byte:[146]"
1030 print" 1 139"
1040 print" 2 140"
1050 print" 3 141"
1060 print" 4 142"
1070 print" 5 143"
1080 geta$:ifa$=""then1080
1090 a=val(a$):ifa<1ora>5then1000
1100 poke895,138+a
1110 print"[147] testing random seed"
1120 print" byte ";a+138;"[157]."
1130 print" press f1[146] to stop."
1140 sys885:goto3000
2000 poke945,4:poke946,169:poke947,255:poke948,133:poke949,176:poke950,96
2002 fora=891to897:pokea,234:next
2005 print"[147] testing basic rnd[146]"
2010 print" command."
2020 print" enter number range:"
2030 print" (0 - 255)"
2035 print" enter two numbers"
2036 print" separated by a comma."
2040 inputa,b
2050 ifa<0ora>255then2000
2060 ifb<0orb>255then2000
2070 print"[147] testing rnd[146] command."
2080 print" range= ";a;"-";b
2090 print" press f1[146] to stop."
2100 x=251:y=176:z=255:r=(abs(a-b))+1:pokey,0
2110 ifa<bthenl=a
2120 ifb<athenl=b
2130 pokex,int((rnd(1)*r)+l):sys885:ifpeek(y)=zthen3000
2140 goto2130
3000 poke198,0:gosub3500
3010 b=7168:c=7678:q=256:l=20:fora=btocstep2
3020 printct,peek(a)+q*peek(a+1):n=n+1:ct=ct+1:ifn=>lthengosub3200
3030 next
3100 print" (press any key)"
3110 geta$:ifa$=""then3110
3120 goto4000
3200 n=0
3210 geta$:ifa$=""then3210
3220 gosub3500:return
3500 print"[147]number","count":return
4000 print"[147] request analysis?"
4002 print" (press y[146] or n[146])"
4004 geta$:ifa$=""then4004
4006 ifa$<>"y"then5000
4008 print"[147] please wait..."
4009 b=7168:c=7678:d=2:tt=0:ct=0:hi=0:lo=65535:zz=0:g=256
4010 fora=btocstepd
4020 n=peek(a)+g*peek(a+1)
4030 ifn=0thenzz=zz+1:goto4040
4035 gosub4500
4040 next
4100 print"[147] random analysis:"
4110 print" total numbers hit:"
4120 print" ";ct
4130 print" total count:"
4140 print" ";tt
4150 print" average count:"
4160 print" ";tt/ct
4170 print" lowest count:"
4180 print" ";lo
4190 print" highest count:"
4200 print" ";hi
4210 print" total zeroes:"
4220 print" ";zz
4230 clr:print"r[146] to repeat analysis."
4240 geta$:ifa$=""then4240
4400 ifa$="r"then3000
4410 goto5000
4500 ct=ct+1:tt=tt+n
4510 ifn>hithenhi=n
4520 ifn<lothenlo=n
4530 return
5000 print"[147] program ended."